package com.example.jinyongjie.test_opengles.programs;

import android.content.Context;

import com.example.jinyongjie.test_opengles.R;

import static android.opengl.GLES20.GL_TEXTURE0;
import static android.opengl.GLES20.GL_TEXTURE_2D;
import static android.opengl.GLES20.glActiveTexture;
import static android.opengl.GLES20.glBindTexture;
import static android.opengl.GLES20.glGetAttribLocation;
import static android.opengl.GLES20.glGetUniformLocation;
import static android.opengl.GLES20.glUniform1i;
import static android.opengl.GLES20.glUniformMatrix4fv;

/**
 * Created by jinyongjie on 17/3/23.
 */
public class ColorShaderProgram extends ShaderProgram {
    private int m_aPositionLocation;
    private int m_uMatrixLocation;
    private int m_uColorLocation;

    public ColorShaderProgram(Context context)
    {
        super(context,R.raw.simple_vertex_shader,R.raw.simple_fragment_shader);

        m_aPositionLocation = glGetAttribLocation(m_program, A_POSITION);
        m_uMatrixLocation = glGetUniformLocation(m_program, U_MATRIX);
        m_uColorLocation = glGetUniformLocation(m_program, U_COLOR);
    }
    public void setUniforms(float[] matrix)
    {
        glUniformMatrix4fv(m_uMatrixLocation, 1, false, matrix, 0);

    }

    public int getPositionAttributeLocation()
    {
        return m_aPositionLocation;
    }
    public int getColorUniformLocation()
    {
        return m_uColorLocation;
    }
}
